package com.simon.hse.activity.safe.safework;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.activity.SignActivity;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

/**
 * 作业安全方案
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_work_safe_plan)
public class WorkSafePlanActivity extends BaseActivity {
    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;

    @ViewInject(R.id.tv_apply_work_permit_xgbg)
    TextView mTv_apply_work_permit_xgbg;

    @ViewInject(R.id.ll_danger_stop_bottom)
    LinearLayout mLl_danger_stop_bottom;

    @ViewInject(R.id.tv_train_record_cancel)
    TextView tvTrainRecordCancel;

    @ViewInject(R.id.tv_train_record_confirm)
    TextView tvTrainRecordConfirm;
    @ViewInject(R.id.iv_common_right)
    TextView ivCommonRight;

    private boolean isShowBottom = false;

    String from;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mTv_common_title.setText("作业安全方案");
        Bundle bundle = getIntent().getExtras();
        from = bundle.getString("from");
        switch (from) {
            //有效
            case "effective":
                ivCommonRight.setVisibility(View.VISIBLE);
                mTv_common_title.setText("作业安全方案");
                tvTrainRecordConfirm.setText("申请取消");
                break;
            //取消审批
            case "cancelApply":
                tvTrainRecordCancel.setVisibility(View.VISIBLE);
                mTv_common_title.setText("申请作业方案");
                tvTrainRecordConfirm.setText("同意");
                tvTrainRecordCancel.setText("不同意");
                break;
            //待审批
            case "pendingApproval":
                tvTrainRecordCancel.setVisibility(View.VISIBLE);
                mTv_common_title.setText("作业安全方案");
                tvTrainRecordConfirm.setText("同意并签名");
                tvTrainRecordCancel.setText("不同意");
                break;
            default:
                mTv_common_title.setText("作业安全方案");
                break;
        }
    }

    @Event(value = {R.id.iv_common_left, R.id.tv_train_record_cancel, R.id.tv_train_record_confirm})
    private void finish(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
                break;
            case R.id.tv_train_record_cancel:
                finish();
                break;
            case R.id.tv_train_record_confirm:
                switch (from) {
                    //有效
                    case "effective":
                        startActivity(new Intent(WorkSafePlanActivity.this,ApprovalCancelWorkPermitActivity.class));
                        finish();
                        break;
                    //取消审批
                    case "cancelApply":
                      finish();
                        break;
                    //待审批
                    case "pendingApproval":
                        startActivity(new Intent(WorkSafePlanActivity.this, SignActivity.class));
                        finish();
                        break;
                    default:
                        break;
                }
        }
    }
}
